/**
 * Created by WLG on 2018/11/9.
 */
let ChatBusinessService = require("../services/chatBusinessService");
let ChatMemInfoService = require("../services/chatMemInfoService");
let ChatMsgService = require("../services/chatMsgService");
let serverConfig = require('../config/serverConfig');
let Router = require('koa-router');
let join = require('path').join;


class chatWebHandlerPart2 {
    static attach(app,io){
        let router = new Router();
        router
            .get([serverConfig.httpNameSpace,"chatAndChatMemInfo"].join("/") , async (ctx, next) => {
                ctx.set("Content-Type", "application/json");
                let param = ctx.query;
                ctx.response.body = await ChatBusinessService.getOneChatAndChatMemInfo(param.memId,param.chatId);
                await next();
            })
            .get([serverConfig.httpNameSpace,"chatMsgListSimple"].join("/") , async (ctx, next) => {
                ctx.set("Content-Type", "application/json");
                let param = ctx.query;
                ctx.response.body = await ChatMsgService.searchChatMsgList(param.chatId,param.sortId);
                await next();
            });

        app.use(router.routes()).use(router.allowedMethods());

        commonUtil.consoleSysInfo("WebHandler初始化完成");
    };
}
module["exports"] = chatWebHandlerPart2;